/**
 * Created by liubin on 2017/6/2.
 */


var DtjCardHelper = function () {

    var that = {};

    that.cardNums = [1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,13,14,15,16,17,18,19,20,21];

    //有鬼子和天九王
    that.allCardGroups_1 = [
        //鬼子
        [[8,12], [8,13]],
        //皇上
        [[20,21]],
        //天九王
        [[1,12], [1,13]],
        //对天
        [[1,1]],
        //对地
        [[2,2]],
        //对人
        [[3,3]],
        //对娥
        [[4,4]],
        //对大五  对长   对二    一样大
        //对大五
        [[5,5]],
        //对长
        [[6,6]],
        //对二
        [[7,7]],
        //对虎头  对金平  对幺六  对幺五   一样大
        //对虎头
        [[8,8]],
        //对金平
        [[9,9]],
        //对幺六
        [[10,10]],
        //对幺五
        [[11,11]],
        //对杂九
        [[12,13]],
        //对杂八
        [[14,15]],
        //对杂七
        [[16,17]],
        //对杂五
        [[18,19]],
        //天杠
        [[1,3],[1,14],[1,15]],
        //地杠
        [[2,3], [2,14], [2,15]],
        //九点
        [[1,10], [1,16], [1,17]],
        [[2,10], [2,16], [2,17]],
        [[3,8]],
        [[4,18], [4,19]],
        [[5,12],[5,13],[6,21],[7,18],[7,19]],
        [[8,14],[8,15],[9,12],[9,13],[11,21]],
        //八点
        [[1,6],[1,11],[1,20]],
        [[2,6],[2,11],[2,20]],
        [[3,5],[3,9]],
        [[4,7]],
        [[5,14],[5,15]],
        [[8,10],[8,16],[8,17],[9,14],[9,15]],
        [[18,21],[19,21]],
        //七点
        [[1,18],[1,19]],
        [[2,18],[2,19]],
        [[3,12],[3,13]],
        [[4,21]],
        [[5,10],[5,16],[5,17],[6,8],[7,21]],
        [[8,11],[8,20],[9,10],[9,16],[9,17]],
        [[12,14],[12,15],[13,14],[13,15]],
        //六点
        [[1,4],[1,7]],
        [[2,4],[2,7]],
        [[3,14],[3,15]],
        [[5,6],[5,11],[5,20],[6,9]],
        [[8,18],[8,19],[9,11],[9,20],[10,12],[10,13]],
        [[12,16],[12,17],[13,16],[13,17]],
        //五点
        [[1,21]],
        [[2,21]],
        [[3,10],[3,16],[3,17]],
        [[4,8]],
        [[5,18],[5,19],[6,12],[6,13],[7,8]],
        [[9,18],[9,19],[10,14],[10,15],[11,12],[11,13]],
        [[12,20],[13,20],[14,16],[14,17],[15,16],[15,17]],
        //四点
        [[1,2]],
        [[3,6],[3,11],[3,20]],
        [[4,5],[4,9]],
        [[5,7],[6,14],[6,15],[7,9]],
        [[8,21],[10,16],[10,17],[11,14],[11,15]],
        [[12,18],[12,19],[13,18],[13,19],[14,20],[15,20]],
        //三点
        [[1,8]],
        [[2,8]],
        [[3,18],[3,19]],
        [[4,12],[4,13]],
        [[5,21],[6,10],[6,16],[6,17],[7,12],[7,13]],
        [[9,21],[10,11],[10,20],[11,16],[11,17]],
        [[14,18],[14,19],[15,18],[15,19],[16,20],[17,20]],
        //二点
        [[1,5],[1,9]],
        [[2,5],[2,9]],
        [[3,4],[3,7]],
        [[4,14],[4,15]],
        [[6,11],[6,20],[7,14],[7,15]],
        [[10,18],[10,19],[11,20]],
        [[12,21],[13,21],[16,18],[16,19],[17,18],[17,19]],
        //一点
        [[0, 0]],
        [[2,12],[2,13]],
        [[3,21]],
        [[4,10],[4,16],[4,17]],
        [[5,8],[6,18],[6,19],[7,10],[7,16],[7,17]],
        [[8,9],[11,18],[11,19]],
        [[14,21],[15,21],[18,20],[19,20]],
        //零点
        [[4,6],[4,11],[4,20],[5,9],[6,7],[7,11],[7,20],[10,21],[16,21],[17,21]]
    ];

    //没有鬼子和天九王
    that.allCardGroups_2 = [
        [[0, 0]],
        //皇上
        [[20,21]],
        [[0, 0]],
        //对天
        [[1,1]],
        //对地
        [[2,2]],
        //对人
        [[3,3]],
        //对娥
        [[4,4]],
        //对大五  对长   对二    一样大
        //对大五
        [[5,5]],
        //对长
        [[6,6]],
        //对二
        [[7,7]],
        //对虎头  对金平  对幺六  对幺五   一样大
        //对虎头
        [[8,8]],
        //对金平
        [[9,9]],
        //对幺六
        [[10,10]],
        //对幺五
        [[11,11]],
        //对杂九
        [[12,13]],
        //对杂八
        [[14,15]],
        //对杂七
        [[16,17]],
        //对杂五
        [[18,19]],
        //天杠
        [[1,3],[1,14],[1,15]],
        //地杠
        [[2,3], [2,14], [2,15]],
        //九点
        [[1,10], [1,16], [1,17]],
        [[2,10], [2,16], [2,17]],
        [[3,8]],
        [[4,18], [4,19]],
        [[5,12],[5,13],[6,21],[7,18],[7,19]],
        [[8,14],[8,15],[9,12],[9,13],[11,21]],
        //八点
        [[1,6],[1,11],[1,20]],
        [[2,6],[2,11],[2,20]],
        [[3,5],[3,9]],
        [[4,7]],
        [[5,14],[5,15]],
        [[8,10],[8,16],[8,17],[9,14],[9,15]],
        [[18,21],[19,21]],
        //七点
        [[1,18],[1,19]],
        [[2,18],[2,19]],
        [[3,12],[3,13]],
        [[4,21]],
        [[5,10],[5,16],[5,17],[6,8],[7,21]],
        [[8,11],[8,20],[9,10],[9,16],[9,17]],
        [[12,14],[12,15],[13,14],[13,15]],
        //六点
        [[1,4],[1,7]],
        [[2,4],[2,7]],
        [[3,14],[3,15]],
        [[5,6],[5,11],[5,20],[6,9]],
        [[8,18],[8,19],[9,11],[9,20],[10,12],[10,13]],
        [[12,16],[12,17],[13,16],[13,17]],
        //五点
        [[1,21]],
        [[2,21]],
        [[3,10],[3,16],[3,17]],
        [[4,8]],
        [[5,18],[5,19],[6,12],[6,13],[7,8]],
        [[9,18],[9,19],[10,14],[10,15],[11,12],[11,13]],
        [[12,20],[13,20],[14,16],[14,17],[15,16],[15,17]],
        //四点
        [[1,2]],
        [[3,6],[3,11],[3,20]],
        [[4,5],[4,9]],
        [[5,7],[6,14],[6,15],[7,9]],
        [[8,21],[10,16],[10,17],[11,14],[11,15]],
        [[12,18],[12,19],[13,18],[13,19],[14,20],[15,20]],
        //三点
        [[1,8]],
        [[2,8]],
        [[3,18],[3,19]],
        [[4,12],[4,13]],
        [[5,21],[6,10],[6,16],[6,17],[7,12],[7,13]],
        [[9,21],[10,11],[10,20],[11,16],[11,17]],
        [[14,18],[14,19],[15,18],[15,19],[16,20],[17,20]],
        //二点
        [[1,5],[1,9]],
        [[2,5],[2,9]],
        [[3,4],[3,7]],
        [[4,14],[4,15]],
        [[6,11],[6,20],[7,14],[7,15]],
        [[10,18],[10,19],[11,20]],
        [[12,21],[13,21],[16,18],[16,19],[17,18],[17,19]],
        //一点
        [[1,12], [1,13]],
        [[2,12],[2,13]],
        [[3,21]],
        [[4,10],[4,16],[4,17]],
        [[5,8],[6,18],[6,19],[7,10],[7,16],[7,17]],
        [[8,9],[11,18],[11,19]],
        [[14,21],[15,21],[18,20],[19,20]],
        //零点
        [[4,6],[4,11],[4,20],[5,9],[6,7],[7,11],[7,20], [8,12], [8,13], [10,21],[16,21],[17,21]]
    ];

    //有鬼子和没天九王
    that.allCardGroups_3 = [
        [[8,12], [8,13]],
        //皇上
        [[20,21]],
        [[0, 0]],
        //对天
        [[1,1]],
        //对地
        [[2,2]],
        //对人
        [[3,3]],
        //对娥
        [[4,4]],
        //对大五  对长   对二    一样大
        //对大五
        [[5,5]],
        //对长
        [[6,6]],
        //对二
        [[7,7]],
        //对虎头  对金平  对幺六  对幺五   一样大
        //对虎头
        [[8,8]],
        //对金平
        [[9,9]],
        //对幺六
        [[10,10]],
        //对幺五
        [[11,11]],
        //对杂九
        [[12,13]],
        //对杂八
        [[14,15]],
        //对杂七
        [[16,17]],
        //对杂五
        [[18,19]],
        //天杠
        [[1,3],[1,14],[1,15]],
        //地杠
        [[2,3], [2,14], [2,15]],
        //九点
        [[1,10], [1,16], [1,17]],
        [[2,10], [2,16], [2,17]],
        [[3,8]],
        [[4,18], [4,19]],
        [[5,12],[5,13],[6,21],[7,18],[7,19]],
        [[8,14],[8,15],[9,12],[9,13],[11,21]],
        //八点
        [[1,6],[1,11],[1,20]],
        [[2,6],[2,11],[2,20]],
        [[3,5],[3,9]],
        [[4,7]],
        [[5,14],[5,15]],
        [[8,10],[8,16],[8,17],[9,14],[9,15]],
        [[18,21],[19,21]],
        //七点
        [[1,18],[1,19]],
        [[2,18],[2,19]],
        [[3,12],[3,13]],
        [[4,21]],
        [[5,10],[5,16],[5,17],[6,8],[7,21]],
        [[8,11],[8,20],[9,10],[9,16],[9,17]],
        [[12,14],[12,15],[13,14],[13,15]],
        //六点
        [[1,4],[1,7]],
        [[2,4],[2,7]],
        [[3,14],[3,15]],
        [[5,6],[5,11],[5,20],[6,9]],
        [[8,18],[8,19],[9,11],[9,20],[10,12],[10,13]],
        [[12,16],[12,17],[13,16],[13,17]],
        //五点
        [[1,21]],
        [[2,21]],
        [[3,10],[3,16],[3,17]],
        [[4,8]],
        [[5,18],[5,19],[6,12],[6,13],[7,8]],
        [[9,18],[9,19],[10,14],[10,15],[11,12],[11,13]],
        [[12,20],[13,20],[14,16],[14,17],[15,16],[15,17]],
        //四点
        [[1,2]],
        [[3,6],[3,11],[3,20]],
        [[4,5],[4,9]],
        [[5,7],[6,14],[6,15],[7,9]],
        [[8,21],[10,16],[10,17],[11,14],[11,15]],
        [[12,18],[12,19],[13,18],[13,19],[14,20],[15,20]],
        //三点
        [[1,8]],
        [[2,8]],
        [[3,18],[3,19]],
        [[4,12],[4,13]],
        [[5,21],[6,10],[6,16],[6,17],[7,12],[7,13]],
        [[9,21],[10,11],[10,20],[11,16],[11,17]],
        [[14,18],[14,19],[15,18],[15,19],[16,20],[17,20]],
        //二点
        [[1,5],[1,9]],
        [[2,5],[2,9]],
        [[3,4],[3,7]],
        [[4,14],[4,15]],
        [[6,11],[6,20],[7,14],[7,15]],
        [[10,18],[10,19],[11,20]],
        [[12,21],[13,21],[16,18],[16,19],[17,18],[17,19]],
        //一点
        [[1,12], [1,13]],
        [[2,12],[2,13]],
        [[3,21]],
        [[4,10],[4,16],[4,17]],
        [[5,8],[6,18],[6,19],[7,10],[7,16],[7,17]],
        [[8,9],[11,18],[11,19]],
        [[14,21],[15,21],[18,20],[19,20]],
        //零点
        [[4,6],[4,11],[4,20],[5,9],[6,7],[7,11],[7,20], [10,21],[16,21],[17,21]]
    ];

    //没有鬼子和有天九王
    that.allCardGroups_4 = [
        [[0, 0]],
        //皇上
        [[20,21]],
        [[1,12], [1,13]],
        //对天
        [[1,1]],
        //对地
        [[2,2]],
        //对人
        [[3,3]],
        //对娥
        [[4,4]],
        //对大五  对长   对二    一样大
        //对大五
        [[5,5]],
        //对长
        [[6,6]],
        //对二
        [[7,7]],
        //对虎头  对金平  对幺六  对幺五   一样大
        //对虎头
        [[8,8]],
        //对金平
        [[9,9]],
        //对幺六
        [[10,10]],
        //对幺五
        [[11,11]],
        //对杂九
        [[12,13]],
        //对杂八
        [[14,15]],
        //对杂七
        [[16,17]],
        //对杂五
        [[18,19]],
        //天杠
        [[1,3],[1,14],[1,15]],
        //地杠
        [[2,3], [2,14], [2,15]],
        //九点
        [[1,10], [1,16], [1,17]],
        [[2,10], [2,16], [2,17]],
        [[3,8]],
        [[4,18], [4,19]],
        [[5,12],[5,13],[6,21],[7,18],[7,19]],
        [[8,14],[8,15],[9,12],[9,13],[11,21]],
        //八点
        [[1,6],[1,11],[1,20]],
        [[2,6],[2,11],[2,20]],
        [[3,5],[3,9]],
        [[4,7]],
        [[5,14],[5,15]],
        [[8,10],[8,16],[8,17],[9,14],[9,15]],
        [[18,21],[19,21]],
        //七点
        [[1,18],[1,19]],
        [[2,18],[2,19]],
        [[3,12],[3,13]],
        [[4,21]],
        [[5,10],[5,16],[5,17],[6,8],[7,21]],
        [[8,11],[8,20],[9,10],[9,16],[9,17]],
        [[12,14],[12,15],[13,14],[13,15]],
        //六点
        [[1,4],[1,7]],
        [[2,4],[2,7]],
        [[3,14],[3,15]],
        [[5,6],[5,11],[5,20],[6,9]],
        [[8,18],[8,19],[9,11],[9,20],[10,12],[10,13]],
        [[12,16],[12,17],[13,16],[13,17]],
        //五点
        [[1,21]],
        [[2,21]],
        [[3,10],[3,16],[3,17]],
        [[4,8]],
        [[5,18],[5,19],[6,12],[6,13],[7,8]],
        [[9,18],[9,19],[10,14],[10,15],[11,12],[11,13]],
        [[12,20],[13,20],[14,16],[14,17],[15,16],[15,17]],
        //四点
        [[1,2]],
        [[3,6],[3,11],[3,20]],
        [[4,5],[4,9]],
        [[5,7],[6,14],[6,15],[7,9]],
        [[8,21],[10,16],[10,17],[11,14],[11,15]],
        [[12,18],[12,19],[13,18],[13,19],[14,20],[15,20]],
        //三点
        [[1,8]],
        [[2,8]],
        [[3,18],[3,19]],
        [[4,12],[4,13]],
        [[5,21],[6,10],[6,16],[6,17],[7,12],[7,13]],
        [[9,21],[10,11],[10,20],[11,16],[11,17]],
        [[14,18],[14,19],[15,18],[15,19],[16,20],[17,20]],
        //二点
        [[1,5],[1,9]],
        [[2,5],[2,9]],
        [[3,4],[3,7]],
        [[4,14],[4,15]],
        [[6,11],[6,20],[7,14],[7,15]],
        [[10,18],[10,19],[11,20]],
        [[12,21],[13,21],[16,18],[16,19],[17,18],[17,19]],
        //一点
        [[0, 0]],
        [[2,12],[2,13]],
        [[3,21]],
        [[4,10],[4,16],[4,17]],
        [[5,8],[6,18],[6,19],[7,10],[7,16],[7,17]],
        [[8,9],[11,18],[11,19]],
        [[14,21],[15,21],[18,20],[19,20]],
        //零点
        [[4,6],[4,11],[4,20],[5,9],[6,7],[7,11],[7,20], [8,12], [8,13], [10,21],[16,21],[17,21]]
    ];

    that.allCardGroups = null,

    that.deskCardScale = 0.4;

    that.cardScale = 0.9;

    that.myInHandCardScale = 1.2;

    //手牌位置
    that.cardInhandPoints = null;

    that.getExistCardNum = function (cardNum) {
        if (cardNum >= 1 && cardNum <= 32){
            return true;
        }
        return false;
    };

    that.getRandomOrderCard = function () {
        var tmpCardNums = this.cardNums;

        var randomOrderCard = [];

        while (tmpCardNums.length > 0){
            var index = parseInt(Math.random() * tmpCardNums.length);
            var num = tmpCardNums[index];
            tmpCardNums.splice(index, 1);

            randomOrderCard.push(num);
        }

        return randomOrderCard;
    };

    that.getDeskCardSize = function () {
        return cc.size(60 * that.deskCardScale, 133 * that.deskCardScale);
    };

    that.getCardSize = function () {
        return cc.size(60 * that.cardScale, 133 * that.cardScale);
    };

    that.getInhandCardSize = function () {
        return cc.size(60 * that.myInHandCardScale, 133 * that.myInHandCardScale);
    };

    that.getSzSize = function () {
        return cc.size(92 * that.cardScale, 95 * that.cardScale);
    };

    that.getInhandCardPos = function (seat) {
        return that.cardInhandPoints[seat];
    };

    that.setCardTypeGroup = function (ruleId) {

        if(ruleId == 1){
            that.allCardGroups = that.allCardGroups_1;
        }else if(ruleId == 2){
            that.allCardGroups = that.allCardGroups_2;
        }else if(ruleId == 3){
            that.allCardGroups = that.allCardGroups_3;
        }else if(ruleId == 4){
            that.allCardGroups = that.allCardGroups_4;
        }

    };

    that.getMyTishiCardGroup = function (otherCardNums, myCardNums, isMyHost) {

        var score = 0;
        var maxScore = 0;
        var myCardOrder = [];
        var myMaxCardOrder = this.getTishiCardGroup(myCardNums);

        for (var i = 0; i < myCardNums.length; i++){
            var num_1 = myCardNums[i];

            for (var j = i + 1; j < myCardNums.length; j++){
                score = 0;
                myCardOrder = [];

                var num_2 = myCardNums[j];
                myCardOrder.push(num_1);
                myCardOrder.push(num_2);

                for (var m = 0; m < myCardNums.length; m++){
                    if(m != i && m != j){
                        myCardOrder.push(myCardNums[m]);
                    }
                }

                var cardGroupHe = 10000;
                var cardGroupIndex_small = that.getCardGroup(myCardOrder[0], myCardOrder[1]);
                var cardGroupIndex_big = that.getCardGroup(myCardOrder[2], myCardOrder[3]);

                if(isMyHost){
                    cardGroupIndex_small -= 1;
                    cardGroupIndex_big -= 1;
                }

                if(cardGroupIndex_small < cardGroupIndex_big){
                    var tmp = cardGroupIndex_small;
                    cardGroupIndex_small = cardGroupIndex_big;
                    cardGroupIndex_big = tmp;
                }

                for (var n = 0; n < otherCardNums.length; n++){

                    var otherNums = otherCardNums[n];

                    var otherCardGroupIndex_small = that.getCardGroup(otherNums[0], otherNums[1]);
                    var otherCardGroupIndex_big = that.getCardGroup(otherNums[2], otherNums[3]);

                    if(cardGroupIndex_small < otherCardGroupIndex_small && cardGroupIndex_big < otherCardGroupIndex_big){
                        score += 2;
                        if (cardGroupIndex_small < 33){
                            score += 2;
                        }
                    }else if(cardGroupIndex_small > otherCardGroupIndex_small && cardGroupIndex_big > otherCardGroupIndex_big){
                        score += 0;
                    }else{
                        score += 1;
                    }
                }

                if(score > maxScore || (score == maxScore && (cardGroupIndex_small + cardGroupIndex_big) < cardGroupHe) ){
                    cardGroupHe = cardGroupIndex_small + cardGroupIndex_big;
                    maxScore = score;
                    myMaxCardOrder = [];
                    for (var k = 0; k < myCardOrder.length; k++){
                        myMaxCardOrder.push(myCardOrder[k]);
                    }
                }
            }
        }

        var tmp = this.getTishiCardGroup(myCardNums);

        var small_1 = that.getCardTypeCHS(that.getCardGroup(myMaxCardOrder[0], myMaxCardOrder[1]));
        var big_1 = that.getCardTypeCHS(that.getCardGroup(myMaxCardOrder[2], myMaxCardOrder[3]));

        var small_2 = that.getCardTypeCHS(that.getCardGroup(tmp[0], tmp[1]));
        var big_2 = that.getCardTypeCHS(that.getCardGroup(tmp[2], tmp[3]));


        cc.log("======" + small_1 + " " + big_1 + " ," + small_2 + " " + big_2);

        return myMaxCardOrder;
    };


    that.getTishiCardGroup = function (cardNums) {

        var maxCardGroup = 10000;
        var maxCardGroupNum = [];
        for (var i = 0; i < cardNums.length; i++) {
            var num_1 = cardNums[i];

            for (var j = i + 1; j < cardNums.length; j++) {
                var num_2 = cardNums[j];

                var cardGroupIndex = this.getCardGroup(num_1, num_2);
                if(cardGroupIndex < maxCardGroup){
                    maxCardGroup = cardGroupIndex;
                    maxCardGroupNum = [];
                    maxCardGroupNum.push(num_1);
                    maxCardGroupNum.push(num_2)
                }
            }
        }

        for (var i=0; i<cardNums.length; i++){
            var num = cardNums[i];
            if(num != maxCardGroupNum[0] && num != maxCardGroupNum[1]){
                maxCardGroupNum.push(num);
            }
        }

        return maxCardGroupNum;
    };

    that.getCardGroup = function (cardNum1, cardNum2) {

        var cardGroupIndex = this.getRealyCardGroup(cardNum1, cardNum2);
        // var tmpIndex = 100000;
        //
        // if(cardNum1 == 20 && cardNum2 != 21){
        //     tmpIndex = this.getRealyCardGroup(21, cardNum2);
        // }else if(cardNum1 == 21 && cardNum2 != 20){
        //     tmpIndex = this.getRealyCardGroup(20, cardNum2);
        // }
        //
        // if(cardNum2 == 20 && cardNum1 != 21){
        //     tmpIndex = this.getRealyCardGroup(21, cardNum1);
        // }else if(cardNum2 == 21 && cardNum1 != 20){
        //     tmpIndex = this.getRealyCardGroup(20, cardNum1);
        // }
        //
        // cardGroupIndex = tmpIndex < cardGroupIndex ? tmpIndex : cardGroupIndex;

        return cardGroupIndex;
    };

    that.getRealyCardGroup = function (cardNum1, cardNum2) {

        for (var i=0; i<this.allCardGroups.length; i++){
            var cardGroups = this.allCardGroups[i];
            for (var j=0; j<cardGroups.length; j++){
                var cardGroup = cardGroups[j];
                if(cardNum1 == cardGroup[0] && cardNum2 == cardGroup[1]
                    || cardNum1 == cardGroup[1] && cardNum2 == cardGroup[0]){
                    return i;
                }
            }
        }

        return 100000;
    };


    //返回牌型对应的中文
    that.getCardTypeCHS = function(cardType){
        var types = [
            "鬼子",
            "皇上",
            "天九王",
            "对天",
            "对地",
            "对人",
            "对娥",
            "对长",
            "对长",
            "对长",
            "对短",
            "对短",
            "对短",
            "对短",
            "对杂九",
            "对杂八",
            "对杂七",
            "对杂五",
            "天杠",
            "地杠",
            "天九",
            "地九",
            "人九",
            "娥九",
            "长九",
            "短九",
            "天八",
            "地八",
            "人八",
            "娥八",
            "长八",
            "短八",
            "杂八",
            "天七",
            "地七",
            "人七",
            "娥七",
            "长七",
            "短七",
            "杂七",
            "天六",
            "地六",
            "人六",
            "长六",
            "短六",
            "杂六",
            "天五",
            "地五",
            "人五",
            "娥五",
            "长五",
            "短五",
            "杂五",
            "天四",
            "人四",
            "娥四",
            "长四",
            "短四",
            "杂四",
            "天三",
            "地三",
            "人三",
            "娥三",
            "长三",
            "短三",
            "杂三",
            "天二",
            "地二",
            "人二",
            "娥二",
            "长二",
            "短二",
            "杂二",
            "天一",
            "地一",
            "人一",
            "娥一",
            "长一",
            "短一",
            "杂一",
            "毕十"
        ];

        return types[cardType];
    };

    //返回表情序列帧
    that.getFaceFrames = function (index) {
        var spriteFrames = [];
        for (var i = 0; i <= 60; i++){
            var frame = cc.spriteFrameCache.getSpriteFrame("emoji_" + index + "_" + i + ".png");
            if (frame == null){
                break;
            }
            spriteFrames.push(frame);
        }
        return spriteFrames;
    };

    that.getAllCardTypeCount = function () {

        var count = 0;
        for (var i=0; i<that.allCardGroups.length; i++){
            count += that.allCardGroups[i].length;
        }


        for (var i=0; i<that.allCardGroups.length; i++){
            for (var j=0; j<that.allCardGroups[i].length; j++){
                var num1 = that.allCardGroups[i][j][0];
                var num2 = that.allCardGroups[i][j][1];

                for (var m=i+1; m<that.allCardGroups.length; m++){
                    for (var n=0; n<that.allCardGroups[m].length; n++){
                        var num3 = that.allCardGroups[m][n][0];
                        var num4 = that.allCardGroups[m][n][1];

                        if((num1 == num3 && num2 == num4)
                        || (num1 == num4 && num2 == num3)){
                            cc.log("有重复:" + num1 + "," + num2);
                        }
                    }
                }
            }
        }

        return count;
    };

    return that;
};

mo.dtjCardHelper = new DtjCardHelper();